package org.example.controller;


import org.example.model.ClassInfo;
import org.example.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/classes")
public class ClassController {
    @Autowired
    private ClassService classService;

    @PostMapping
    public int addClass(@RequestBody ClassInfo classInfo) {
        return classService.addClass(classInfo);
    }

    @PutMapping
    public int updateClass(@RequestBody ClassInfo classInfo) {
        return classService.updateClass(classInfo);
    }

    @DeleteMapping("/{id}")
    public int deleteClass(@PathVariable Long id) {
        return classService.deleteClass(id);
    }

    @GetMapping("/{id}")
    public ClassInfo getClassById(@PathVariable Long id) {
        return classService.getClassById(id);
    }

    @GetMapping
    public List<ClassInfo> getAllClasses() {
        return classService.getAllClasses();
    }
}